<!--带有穿梭框的初代版本-->
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>职工短信</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/static/layuiadmin/layui/css/layui2.css" media="all">
</head>

<body layadmin-themealias="default">
<div class="layui-fluid" style="margin-top: 13px">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">职工短信</div>
                <div class="layui-card-body" pad15>

                    <div class="layui-form" wid100="" lay-filter="">
                        <div class="layui-form-item">
                            <label class="layui-form-label">消息模板</label>
                            <div class="layui-input-block">
                                <select name="smsTemplate" lay-verify="">
                                    <option value="-1" selected>请选择通知模板</option>
                                    {volist name="informData" id="vo"}
                                    <option value="{$vo['key']}" >{$vo['value']}</option>
                                    {/volist}
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item" >
                            <label class="layui-form-label">添加班级</label>
                            <div class="layui-input-block">
                                <div id="test4" class="demo-transfer"></div>
                            </div>
                        </div>
                        <hr>
                        <input type="hidden" name="courseInfo" id="courseInfo">
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="sendSMS">发送短信</button>
                                <button id="reset" class="layui-btn layui-btn-primary">重新填写</button>
                            </div>
                        </div>

                    </div>

                </div>
            </div>
        </div>
    </div>
</div>






<script src="/static/indexTemplate/lib/jquery-2.1.4.js"></script>
<script src="/static/layuiadmin/layui/layui.js"></script>

<script>
    function getTransferData(){
        var val = '';
        $.ajax({
            url:"{:url('admin/admin/getCourseData')}?role=admin",
            type:"post",
            dataType:"json",
            async:false,
            success:function(res){
                val = res;
            },
            error:function (res) {
                return '';
            }
        })
        return val;
    }

    $(function () {
        layui.config({
            base: '/static/layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form',"laydate","transfer"], function () {
            var $ = layui.$
                , form = layui.form
                ,transfer=layui.transfer;
            form.on('submit(sendSMS)', function (data) {
                //{cou_adm_id: "1",
                // courseInfo: "[{"value":7,"title":"跨文化交际第一期"},{"value":6,"title":"初三代数题目训练1"}]"}
                var field=data.field;
                if(field.smsTemplate==="-1"){
                    layer.msg("请选择通知模板", { icon: 5, time: 1500 }, function () {

                    });
                    return false;
                }else  if(field.courseInfo===""){
                    layer.msg("请选择课程", { icon: 5, time: 1500 }, function () {

                    });
                    return false;
                }
                $.ajax({
                    type: 'POST',
                    url: "{:url ('admin/admin/adminSendSms')}",
                    dataType: 'json',
                    data: field,
                    async: true,
                    success: function (res) {
                        if (res.code == 1) {
                            layer.msg(res.msg, { icon: 1, time: 1500 }, function () {
                                window.location.reload();
                            });
                        } else {
                            layer.msg(res.msg, { icon: 5, time: 1500 }, function () {
                                window.location.reload();
                            });
                        }
                    }
                });

            });
            //显示搜索框
            transfer.render({
                id:"transfer"
                ,elem: '#test4'
                ,data: getTransferData()
                ,title: ['全部班级', '已选中班级']
                ,width:"400"
                ,height:"500"
                ,showSearch: true
                ,onchange: function(data, index){
                    //获得右侧数据
                    var getData = transfer.getData('transfer');
                    data=JSON.stringify(getData)
                    $("#courseInfo").val(data);
                }
            })

        });
    });

</script>
</body>
</html>
